from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import set_cutscene, get_game
from items.knife import Knife
from items.scuba_suit import Scuba_Suit
#from items.keys import Scuba_Suit
#from items.keys import Glow_Stick

class SpeedBoat(Room):
    
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        
        
        # add inventory items
        self.add_item(Scuba_Suit())
        self.add_item(Knife())
        #self.add_item(Scuba_Suit())
        #self.add_item(Glow_Stick())
        self.add_action(In)
        
        
        # build list of actions
        #if 'scuba_diving' in self.inventory:
        #    self.add_action(In)    
    
    # return description of room.
    def get_description(self):
        return '''
        You are on your boat on the Atlantic Ocean right above the site where the wreckage of pirate ship lies 5Kms below the sea level.
        There is no sign of land in sight. If you are brave enough, you can jump into the water and go looking for hidden treasures in the wreckage! 
        But you need to watch out for the deadly sea monsters!
        '''
    # return image of room
    def get_image(self):
        return 'speed_boat.jpg'
         

class SpeedBoatHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return SpeedBoat

# define actions for this room

class In(Action):
    def __init__(self):
        Action.__init__(self, "In")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Dive In"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        game = get_game()
        player = game.get_player()
        if 'scuba_suit' in player.inventory:
            return 'underwater'
        else:
            set_cutscene("You cannot go underwater without the scuba equipment.")
            return 'speed_boat'
        
    def do_action(self,game,room,request):
        game = get_game()
        player = game.get_player()
        if 'scuba_suit' in player.inventory:
            return set_cutscene('''<audio autoplay="autoplay">
            <source src="images/water_splash.wav" type="audio/wav" />
            Your browser does not support this audio
            </audio>''')
        else:
            return ()
      
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"